﻿<%@ include file="../finance/common_page_top.jsp" %>
<!--成本对账-初步对账-添加发票 -->
<form class="qry-form" style="display: none;">
	<input type="hidden" name="page.currentPage" value="1" />
	<input type="hidden" name="page.showCount"  value="10"/>
	<input type="hidden" id="checkId" name="checkId" value="${checkId}"/>
	<td> <button type="button"
				 class="btn btn-success js_left_query">查询</button></td>
</form>
<div class="position-relative">
	<table style="width:100%;">
		<tr>
			<td style="vertical-align:top;">
				<a title="" class="btn btn-mini btn-info js_btn_add">
					<i class="ace-icon fa bigger-120">添加发票</i>
				</a>
				<a title="" class="btn btn-mini btn-info js_btn_del">
					<i class="ace-icon fa bigger-120">删除发票</i>
				</a>
			</td>
		</tr>
	</table>
</div>
<form id="add-form" style="display: none;">
	<table style="width:100%;padding-left: 5px;">
		<tr>
			<td>
				<div>发票号&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="code" /></div>
			</td>
			<td>
				<div>发票类型
					<%--<input type="text" />--%>
					<%--零票，普3，普6，普11，专3，专6，专11，专17--%>
					<select name="invoiceType">
						<option value="统一发票">统一发票</option>
						<option value="普3">普3</option>
						<option value="普6">普6</option>
						<option value="普11">普11</option>
						<option value="专3">专3</option>
						<option value="专6">专6</option>
						<option value="专11">专11</option>
					</select>
				</div>
			</td>
		</tr>
		<tr>
			<td>
				<div>币&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;种<select name="currency">
					<option value="RMB">RMB</option>
					<option value="USD">USD</option>
				</select></div>
			</td>
			<td>
				<div>汇&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;率
					<input type="text" name="ratio" value="${data.exchangeRatio}" /></div>
			</td>
		</tr>
        <tr>
            <td>
                <div>开票时间<input class="date-picker" name="crtDate"
								type="text" data-date-format="yyyy-mm-dd" />
				</div>
            </td>
            <td>
                <div>收票时间<input class="date-picker" name="rcvDate"
								type="text" data-date-format="yyyy-mm-dd"/>
				</div>
            </td>
        </tr>
		<tr>
			<td>
				<div>发票金额<input type="text" name="amount"
								value="${data.checkAmount}"/></div>
			</td>
			<td>
				<div>结算单位<input type="text" name="settlementCompany"
								value="${data.checkDeptName}" />
				</div>
			</td>
		</tr>

        <tr>
            <td>
                <div>来票方式<select type="text" name="rcvMode" >
					<option value="内部转交">内部转交</option>
					<option value="快递">快递</option>
				</select>
				</div>
            </td>
            <td>
                <div>发票备注<input type="text" name="remark"/></div>
            </td>
        </tr>
		<tr>
			<td colspan="4" style="text-align: center">
				<input type="button" value="保存" id="btn_save"/>
				<input type="button" value="取消" id="btn_cancel"/>
			</td>
		</tr>
	</table>
</form>
<div class="table-layout">
	<table id="invoice-list-table" class="table table-striped table-bordered table-hover"
		   style="margin-top:5px;">
		<thead>
		<tr>
			<th class="center" style="width:35px;">
				<label class="pos-rel">
					<input type="checkbox" class="ace js_selectAll" id="zcheckbox"/>
					<span class="lbl"></span></label>
			</th>
			<th class="center">发票号</th>
			<th class="center">发票类型</th>
			<th class="center">币种</th>
			<th class="center">汇率</th>
			<th class="center">发票金额</th>
			<th class="center">开票时间</th>
			<th class="center">收票时间</th>
			<th class="center">来票方式</th>
			<th class="center">结算单位</th>
			<th class="center">录入日期</th>
			<th class="center">备注</th>
		</tr>
		</thead>
		<tbody>
		</tbody>
	</table>
</div>


<%--<script type="text/javascript"
		src="static/js/settlement/check_cost_index.js?${staticFileVer}"></script>--%>
<script>
	$(document).ready(function () {
		//日期框
		$('.date-picker').datepicker({autoclose: true,todayHighlight: true});

		$("#btn_save").click(function () {
			var data = $("#add-form").serializeObject();
			data.checkId= $("#checkId").val();
			XCF.callService("post",ctx+"/invoiceTitleManage/save",
					data,function (data) {
				if(data.ok){
					//$("#simple-table tbody").html(data.list);
					init();

				}
			});
		});
		$("#btn_cancel").click(function () {
			$("#add-form").css("display","none");
		});
		$(".js_btn_add").click(function () {
			$("#add-form").css("display","block");
		});
		$(".js_btn_del").click(function () {
			//$("#add-form").css("display","block");
			var ids = "";
			$.each($("#invoice-list-table").find("input[name='ids']:checked"),
					function (idx,item) {
						ids = ids.concat(",").concat(item.id);
					});
			if (ids.length<1){
				alert("请选择发票信息！");
				return;
			}
			var data = {ids:ids.substring(1)};
			XCF.callService("post",ctx+"/invoiceTitleManage/delete",
				data,function (data) {
					if(data.ok){
						//$("#simple-table tbody").html(data.list);
						init();
					}
				});
		});

		var init = function() {
			$("#add-form").css("display","none");
			var c = $("#checkId").val();
			console.log("checkId="+c);
			var param = $(".qry-form").serialize();
			//初始化列表
			XCF.callService(
				"post", ctx + "/costAcct/listReceipt", param,
				function (data) {
					$("#invoice-list-table tbody").html(data);
				},null,"html");

			//$("#add-form").reset();
		};
		init();
		$(".js_left_query").click(init);
	});
</script>
<%@ include file="../finance/common_page_bottom.jsp" %>

</body>
</html>